package sicnu.cs.aps.rest;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import sicnu.cs.aps.common.ResultInfo;
import sicnu.cs.aps.common.ResultInfoUtil;
import sicnu.cs.aps.domain.dto.CollegeInfoDto;
import sicnu.cs.aps.domain.entity.Activity;
import sicnu.cs.aps.domain.entity.CollegeInfo;
import sicnu.cs.aps.domain.entity.Major;
import sicnu.cs.aps.domain.form.QueryForm;
import sicnu.cs.aps.service.ICollegeInfoService;
import sicnu.cs.aps.service.IMajorInfoService;

import java.util.List;

/**
 * 以下接口均不需要权限
 *
 * @author lucker
 * @date 2022/5/30 15:55
 */
@Slf4j
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
@Api(tags = {"全局模块（AUTH）"})
public class AuthResource {
    private final ICollegeInfoService collegeInfoService;
    private final IMajorInfoService majorInfoService;



    @ApiOperation(value = "分页查询学院列表", notes = "参数：name")
    @GetMapping("/getCollegeByName")
    public ResultInfo<PageInfo<CollegeInfoDto>> getCollegeByName(@RequestBody QueryForm queryForm) {
        return ResultInfoUtil.buildSuccess(collegeInfoService.getCollegeInfoByName(queryForm));
    }

    @ApiOperation(value = "获取全部学院")
    @GetMapping("/getCollegeList")
    public ResultInfo<List<CollegeInfo>> getCollegeList() {
        return ResultInfoUtil.buildSuccess(collegeInfoService.getCollegeInfoList());
    }

    @ApiOperation(value = "获取全部专业")
    @GetMapping("/getMajorList")
    public ResultInfo<List<Major>> getMajorList() {
        return ResultInfoUtil.buildSuccess(majorInfoService.list());
    }

}
